#!/usr/bin/ruby
# -*- ruby -*-
MAKEFILE="ext/Makefile.#{RUBY_VERSION}"
BASEDIR=File.dirname(__FILE__)
require 'rubygems'
require 'hoe'
require 'fileutils'
task :default => [:compile]
task :compile => ["ext/alglib_ext.so"]
task :clean do
    FileList.new("ext/**/*.o","ext/**/*.so","ext/Makefile.*").each {|file|
    FileUtils.rm(file)
    }
end

file MAKEFILE => "ext/extconf.rb" do |t|
  Dir.chdir("#{BASEDIR}/ext")
  ruby %{extconf.rb}
  Dir.chdir("#{BASEDIR}")
end

file "ext/alglib_ext.so" => Dir.glob("ext/*.i")+[MAKEFILE, "ext/alglib/alglib_util.cpp", "ext/alglib/alglib_util.h"] do |t|
    Dir.chdir "#{BASEDIR}/ext"
    ruby %{-S rake}
    Dir.chdir BASEDIR
end
require File.dirname(__FILE__)+'/lib/alglib_version.rb'
Hoe.spec 'alglib' do
  self.version=Alglib::VERSION
  self.rubyforge_name = 'ruby-statsample' # if different than 'alglib'
  self.developer('Claudio Bustos', 'clbustos@gmail.com')
  self.spec_extras= {'extensions' => ['ext/extconf.rb']}
  self.url = "http://rubyforge.org/projects/ruby-statsample/"
end

# vim: syntax=ruby
